//
//  UIImage+ZQK.m
//  ZQKweibo
//
//  Created by laouhn on 15/11/10.
//  Copyright (c) 2015年 宇哥. All rights reserved.
//

#import "UIImage+ZQK.h"

@implementation UIImage (ZQK)


+ (UIImage *)imageWithName:(NSString *)name{
    
    if (iOS7) {
        NSString *newName = [name stringByAppendingString:@"_os7"];
        UIImage *image = [UIImage imageNamed:newName];
        if (image == nil) {//没有_os7后缀的图片
            image = [UIImage imageNamed:name];
        }
        return image;
    }
    //非ios7
    return [UIImage imageNamed:name];

}


+ (UIImage *)resizedImageWithName:(NSString *)name{
    UIImage *image = [self imageWithName:name];
    return [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];
}


+(UIImage *)imageWithLineWithImageView:(UIImageView *)imageView{
    CGFloat width = imageView.frame.size.width;
    CGFloat height = imageView.frame.size.height;
    UIGraphicsBeginImageContext(imageView.frame.size);
    [imageView.image drawInRect:CGRectMake(0, 0, width, height)];
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
    CGFloat lengths[] = {10,5};
    CGContextRef line = UIGraphicsGetCurrentContext();
    CGContextSetStrokeColorWithColor(line,[UIColor redColor].CGColor);
    CGContextSetLineDash(line, 0, lengths, 1);
    CGContextMoveToPoint(line, 0, 1);
    CGContextAddLineToPoint(line, width-10, 1);
    CGContextStrokePath(line);
    return  UIGraphicsGetImageFromCurrentImageContext();
}



@end
